package gui;

import WeiQi.Chess;

import java.awt.Container;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
// import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class index {
       public index() {
        JFrame f = new JFrame("主界面");
        f.setVisible(true);
		f.setSize(400,400);
        f.setLocationRelativeTo(null);
        Container con = f.getContentPane();
        con.setLayout(new GridLayout(5,1));
        JPanel pan1 = new JPanel();
        JLabel title = new JLabel("西安交通工程学院");
        title.setFont(new Font("宋体", Font.BOLD,30));
        pan1.add(title);
        con.add(pan1);

        //内容1
        JPanel pan2 = new JPanel();
        JLabel game = new JLabel("玩游戏");
       
        JButton button = new JButton("猜数字游戏");
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            new guessnum();
                        }
                    });
            }
        });
        JButton button1 = new JButton("围棋游戏");
        
        // 将按钮添加到面板
        pan2.add(game);
        pan2.add(button);
        pan2.add(button1);
        con.add(pan2);
           button1.addActionListener(new ActionListener() {
               @Override
               public void actionPerformed(ActionEvent e) {
                   SwingUtilities.invokeLater(new Runnable() {
                       public void run() {
                           new Chess("围棋游戏");
                       }
                   });
               }
           });

        
        //内容2
        JPanel pan3 = new JPanel();
        JLabel math = new JLabel("进行计算");
       
        JButton button3 = new JButton("简单计算器");
        button3.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            new calc();
                        }
                    });
            }
        });
       
        JButton button4 = new JButton("图形计算器");
        button4.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            new circlecalc();
                        }
                    });
            }
            
            
        });
        // 将按钮添加到面板
        pan3.add(math);
        pan3.add(button3);
        pan3.add(button4);
        con.add(pan3);


        //内容3
        JPanel pan4 = new JPanel();
        JLabel info = new JLabel("管理信息");
       
        JButton button5 = new JButton("个人信息管理");
        button5.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            new investigation();
                        }
                    });
            }
            
            
        });
        JButton button6 = new JButton("学生信息管理");
        button6.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            new studentinfo();
                        }
                    });
            }
            
            
        });
        // 将按钮添加到面板
        pan4.add(info);
        pan4.add(button5);
        pan4.add(button6);
        con.add(pan4);


        //最后
        JPanel pan5 = new JPanel();
        JButton button7 = new JButton("取消");
        button7.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                          f.dispose();  
                        }
                    });
            }
            
            
        });
        pan5.add(button7);
        con.add(pan5);
       }
}
